﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using homework5;

namespace OrderWinform
{
    public partial class FormAddOrder : Form
    {
        public OrderService os;
        public FormAddOrder(OrderService os)
        {
            InitializeComponent();
            this.os = os;
            using(OrderContext context =new OrderContext())
            {
                bdsCustomer.DataSource = context.Goods.ToList();
            }
        }

        private void btnOK_Click(object sender, EventArgs e)
        {
            try
            {
            Order order = new Order((Customer)bdsCustomer.Current, new OrderDetails(Int32.Parse(txtID.Text),new List<Goods> { new Goods(1,"0",0,0)}));
                os.Add(order);
            this.Close();
            }catch(Exception ex)
            {
                MessageBox.Show("信息输入不正确");
            }
        }
    }
}
